package com.MusicWeb.servlet;

import com.MusicWeb.entity.Music;
import com.MusicWeb.entity.User;
import com.MusicWeb.service.UsermusicService;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/musicdel")
//todo: 音乐删除
//http://localhost:8080/musicdel?id=?
public class MusicDelServlet extends HttpServlet {
    UsermusicService usermusicService = new UsermusicService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        User user = (User) req.getSession().getAttribute("user");
        Integer id = Integer.parseInt(req.getParameter("id"));
//        if (user.getId() == 1) {
            if (usermusicService.del(id)) {
                req.getSession().setAttribute("msg", "删除成功");
            } else {
                req.getSession().setAttribute("msg", "删除失败");
            }
//        }

    }
}
